#ifndef EDITOR_HOOKS_H
#define EDITOR_HOOKS_H

class M_Code_Editor;
class m_SmartIndentPlugin;
class wxScintillaEvent;

namespace EditorHooks {
  class HookFunctorBase {
    public:
      virtual ~HookFunctorBase() {}
      virtual void Call( M_Code_Editor*, wxScintillaEvent& ) const = 0;
  };
  template<class T> class HookFunctor : public HookFunctorBase {
    public:
      typedef void ( T::*Func )( M_Code_Editor*, wxScintillaEvent& );
      HookFunctor( T* obj, Func func ) : m_pObj( obj ), m_pFunc( func ) { ; }
      virtual void Call( M_Code_Editor* editor, wxScintillaEvent& event ) const {
        if( m_pObj && m_pFunc ) {
          ( m_pObj->*m_pFunc )( editor, event );
        }
      }
    protected:
      T* m_pObj;
      Func m_pFunc;
  };

  extern int RegisterHook( HookFunctorBase* functor );
  extern HookFunctorBase* UnregisterHook( int id, bool deleteHook = true );
  extern bool HasRegisteredHooks();
  extern void CallHooks( M_Code_Editor* editor, wxScintillaEvent& event );
  class cbSmartIndentEditorHookFunctor : public HookFunctorBase {
    public:
      cbSmartIndentEditorHookFunctor( m_SmartIndentPlugin* plugin );
      virtual ~cbSmartIndentEditorHookFunctor() {}
      virtual void Call( M_Code_Editor* editor, wxScintillaEvent& event ) const;
    private:
      m_SmartIndentPlugin* m_plugin;
  };
}

#endif
